package com.example.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.ExamQuestion;

@Mapper
public interface ExamQuestionMapper extends BaseMapper<ExamQuestion> {
    
    @Select("SELECT * FROM exam_questions WHERE exam_id = #{examId}")
    List<ExamQuestion> findByExamId(@Param("examId") Long examId);
    
    @Select("SELECT * FROM exam_questions WHERE question_id = #{questionId}")
    List<ExamQuestion> findByQuestionId(@Param("questionId") Long questionId);
    
    @Select("SELECT * FROM exam_questions WHERE exam_id = #{examId} AND question_id = #{questionId}")
    ExamQuestion findByExamIdAndQuestionId(@Param("examId") Long examId, @Param("questionId") Long questionId);
    
    @Delete("DELETE FROM exam_questions WHERE exam_id = #{examId}")
    int deleteByExamId(@Param("examId") Long examId);
    
    @Delete("DELETE FROM exam_questions WHERE question_id = #{questionId}")
    int deleteByQuestionId(@Param("questionId") Long questionId);
    
    @Delete("DELETE FROM exam_questions WHERE exam_id = #{examId} AND question_id = #{questionId}")
    int deleteByExamIdAndQuestionId(@Param("examId") Long examId, @Param("questionId") Long questionId);
} 